home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group99a.txt
/
000040_icon-group-sender _Tue Feb 23 14:51:48 1999.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id OAA04732
for icon-group-addresses; Tue, 23 Feb 1999 14:50:53 -0700 (MST)
Message-Id: <199902232150.OAA04732@baskerville.CS.Arizona.EDU>
From: "Frank Lhota" <lhotaf@lexma.meitech.com>
To: <icon-group@optima.CS.Arizona.EDU>
Subject: Bridging Icon and C Calls
Date: Tue, 23 Feb 1999 12:03:24 -0500
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Recently, there have been some discussion of the Icon facility for calling
external C functions. This facility varies widely from platform to platform,
but it basically consists of calling loadfunc to load a C function from a
dynamic library, then calling the function via the Icon callout function (or
directly in the case of Unix).
The problem with this facility is that it can only be used for C functions
specifically written for Icon. The C function must accept Icon descriptors
as parameters. You generally cannot call a typical external C function from
Icon without first writing a "skin" function that does Icon-to-C argument
translation.
This would be particularly useful under Win 95 / 98 / NT, where the system
services all take the form of functions in dynamic link libraries. The
Windows API has hundreds of functions, many of which would be handy to use
under Icon. These functions cannot be used, however, without some additional
C work to turn Icon arguments into C arguments.
What would be nicer if we could create a facility by which callout would
automatically convert Icon parameters to C, e.g. if there is an external
function foo declared as
int foo ( int n, double x );
then to call this function from Icon, we first load it with loadfunc, then
do this call:
callout ( "foo", 3, 4.5 )
There are numerous complications with doing this. C includes integers and
floating point numbers of various sizes, whereas Icon programmers are
shielded from such concerns. C also uses pointers for many parameters, so we
need to come up with Icon support for this. Pointer parameters can be
implemented using an Icon record, e.g.
record Pointer ( value )
# ...
# function bar declared as
# void bar ( int *ip );
callout ( "bar", ip := Pointer ( 0 ) )
# ip.value updated by callout
I have some ideas about how this facility could be designed, and
implemented. Before proceeding this much further, however, I would like some
feedback. Would other Icon programmers find this useful? If I complete
something like this for NT, could others help me port this to other
platforms?